-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ScopedBuffer #415
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. I like this pattern a lot. Much nicer than repeating ourselves all over the place.
Left a few comments for you to consider. Have approved, so merge it whenever you're happy with it, or let me know if you want me to take another look later on.
#if NET8_0 || NETSTANDARD2_1 | ||
#if NET8_0_OR_GREATER || NETSTANDARD2_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this. I searched and couldn't find any other instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, also searched -- and only one I found!
var keyRefs = ArrayPool<byte>.Shared.Rent(count); | ||
Span<byte> keyRefs = stackalloc byte[count]; // <= 255 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we convert the comment into a Debug.Assert(count <= 255)
instead? It provides a little more safety and is clearer as far as documenting intent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comment to be clearer (count is an unsigned byte, with a safe range) -- no need for an assert. The comment saves a second when auditing the stackalloc call sites.
@@ -193,17 +195,11 @@ namespace MetadataExtractor.IO; | |||
} | |||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the else block any more? Looks like the size check could be moved into a ternary conditional and the two blocks collapsed into one, as you've done elsewhere in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unified the logic across all the readers. much tidier.
Addressed all feedback, and double checked against regressions. Merged! |
Looks great, thanks. FYI I will be less online over the next week but will do my best to review any PRs. |
This PR extracts the ScopedBuffer work from #406
Local regression testing shows no diffs.
@drewnoakes Ready for review.